import React from "react";
import { Button, message } from "antd";

export default function Bar() {
  const handleToCopyText = () => {
    const copyDom = document.querySelector(".translateResult");
    if (copyDom.innerHTML !== "") {
      navigator.clipboard.writeText(copyDom.innerHTML).then(() => {
        message.success("复制成功！");
      });
    } else {
      message.warning("没有内容");
    }
  };
  return (
    <>
      <Button type="primary" onClick={handleToCopyText}>
        点击复制
      </Button>
      <p className="translateResult">大家好才是真的好</p>
    </>
  );
}
